<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/static/commons/taglibs.jsp"%>
<%@ include file="/static/commons/meta.jsp"%>
<%@ include file="/static/commons/jquery-easyui.jsp"%>
<html >
	 <head>
 		<title>${title }</title>
 		 <link rel="stylesheet" href="${ctx }/static/styles/basic/basic.css" />
		 <link rel="stylesheet" href="${ctx }/static/styles/frame/main.css" />
		 <link rel="stylesheet" href="${ctx }/static/styles/frame/searchBtn.css" />
		 <link rel="stylesheet" href="${ctx }/static/styles/frame/searchCondition.css" />
	    <!-- js -->
 		<script type="text/javascript" src="${ctx}/static/scripts/check_all.js"></script>
 		<script type="text/javascript" src="${ctx}/static/scripts/set_select.js"></script>
 		<script type="text/javascript" src="${ctx}/static/scripts/waiting.js"></script>
 		<script type="text/javascript" src="${ctx}/static/scripts/crud.js"></script>
 		<script type="text/javascript" src="${ctx}/static/scripts/common.js"></script>
 		<script type="text/javascript" src="${ctx}/static/scripts/util.js"></script>
 		<script type="text/javascript" src="${ctx}/static/scripts/WdatePicker/WdatePicker.js"></script>
		
	</head>
  <body onload="init()">
		<form action="${ctx}/taskAssign/list" method="post">
  			<input type="hidden" name="RequestVerificationToken" value="${RequestVerificationToken}" />
  			<input type="hidden" name="p_orderType" value="2" />
			<div class="width_100 group_box">
				<div class="group_search width_100">
               	 	<vvise:select id="custId" name="p_custId" sqlname="getCust"
				            ifSearch="true" displayText="用户单位" />
					<vvise:searchInput id="orderId" name="p_orderId" displayText="订单编号" />
					<vvise:searchInput id="orderNo" name="p_orderNo" displayText="序号" />
					<vvise:searchInput id="teamNo" name="p_teamNo" displayText="队号" />
					<vvise:searchInput id="startDate" name="p_startDate" defVal="${startDate}" 
			                endId="endtDate" endName="p_endtDate" endDefVal="${endDate}"
			                 type="time2" displayText="接单时间" dateFormat="yyyy-MM-dd"/>
               	 	<div class="clear_both"></div>
               	 	<vvise:searchInput id="tester" name="p_tester" displayText="检测人员" />
					<vvise:searchInput id="startDate1" name="p_startDate1" endId="endtDate1" endName="p_endtDate1"
			                 type="time2" displayText="完成时间" dateFormat="yyyy-MM-dd"/>
			        <div class="clear_both"></div>
				</div>
				<vvise:funMenu menuId="${menuId}" />
			</div>
        </form>
        <div class="listFrame">
        	<iframe name="listFrame" id="listFrame" frameBorder="0"
				scrolling="auto" style="width: 100%;height:100%;"></iframe>
        </div>
	</body>
	<script type="text/javascript">
  		var headers = {};
		headers['__RequestVerificationToken'] = "${RequestVerificationToken}";
			//回车事件
		document.onkeydown = keyKistener;
		function keyKistener(e){
			e = e ? e:event;
			if(e.keyCode == 13){
				try{
					search();
				}catch(e){}
			}
		}
		function init(){
			set_iframe_h();
			$(window).resize(function(){
				set_iframe_h();
			});
			search();
			$('.easyui-combobox').combobox();
		}
		//设置ifream 高度
		function set_iframe_h(){
			var win_height  = $(window).height();
			var func_line_h = $('.group_box').outerHeight(true);
			var list_height = win_height - func_line_h;
			$('.listFrame').css('height',list_height-10);
		}
		function search(){
			waiting();
			document.forms[0].target = "listFrame";
			document.forms[0].submit();
		}
		
		function task(){
			var pp = parent;
			var ecForm = listFrame.document.all.ec;
			if(!checkSelect(ecForm.id,false,'任务分配'))
				return;
			var id = get_checkbox_value(ecForm.id);
			
			var arr = id.split('@@');
			/* 
			if(arr[1]==1){
				pp.$.messager.alert('操作提示','该订单已分配，不可重新分配！','warning');
				return;
			}
			*/
			id = arr[0];
			doCreate("任务分配信息",pp.width2,360,"${ctx}/taskAssign/edit?orderId="+id+"&orderType=2&type="+arr[2]);
		}
		
		function save(){
			var pp = parent;
			var editFrame = pp.winFrame;
			var id = editFrame.$('#orderId').val();
			var count1 = editFrame.$('#count1').val();
			var count2 = editFrame.$('#count2').val();
			var count3 = editFrame.$('#count3').val();
			
			if(!pp.validData("leaderId","请选择组长！"))
				return;
				
			if(!pp.validData("completeDate","请选择完成日期！"))
				return;
			
			if(count1 != 0){
				if(!pp.validData("userName1","请选择气瓶检测人员！"))
				return;
			}	
			if(count2 != 0){
				if(!pp.validData("userName2","请选择空呼检测人员！"))
				return;
			}	
			if(count3 != 0){
				if(!pp.validData("userName3","请选择气体检测仪检测人员！"))
				return;
			}	
				
			doSave("${ctx}/taskAssign/save", id);
		}
		
		
		/* orderId:订单号
		assignId:分配单ID
		type: 任务类别 wx, jc*/
		function view(orderId, assignId, type){
			var pp = parent;
			//未分配查订单明细，已分配查看分配信息
			if(!isEmpty(assignId)){
				doView("任务分配信息",pp.width2, 300,"${ctx}/taskAssign/edit?orderId="+orderId+"&view=view&orderType=2");
			}else{
				doView("接单信息",pp.width3+420, 700, "${ctx}/bsOrder/edit?orderId="+orderId+"&view=view&orderType=2&taskType="+type);
			}
		}
		
		function getUserList(userType, taskType){
			var pp = parent;
			var editFrame = pp.winFrame;
			var userId = editFrame.$('#userId'+userType).val();
			pp.openWindow("选择人员",pp.width1,400,"${ctx}/taskAssign/getUser?orderType=2&userId="+userId+"&taskType="+taskType,[{
				text:'保存',
				iconCls:'icon-ok',
				handler:function(){
					saveUser(userType, taskType);
				}
			},{
				text:'取消',
				iconCls:'icon-no',
				handler:function(){
					pp.closeWindow('winDiv2');
				}
			}],'','winDiv2');
		}
		
		function saveUser(userType, taskType){
			var pp = parent;
			var editFrame = pp.winFrame;
			var listFrame = pp.winFrame2;
			var ids = "";
			var ecForm = listFrame.document.all.ec;
			if(!checkSelect(ecForm.id,true))
				return;
			ids = get_checkbox_values(ecForm.id,',');
			
			var userId = "";
			var userName = "";
			/* if('wx'==taskType){
				userId = ids.split('||')[0];
				userName = ids.split('||')[1];
			}else{ */
				var idd = ids.split(",");
				if(idd.length!=2){
					pp.$.messager.alert('操作提示','请同时选择检测员和核验员两人！','warning');
					return;
				}
				for(var i in idd){
					if(userId){
						userId+=',', userName+='，';
					}
					userId += idd[i].split('||')[0];
					userName += idd[i].split('||')[1];
				}
			/* } */
			editFrame.$('#userId'+userType).val(userId);
			editFrame.$('#userName'+userType).val(userName);
			editFrame.addLeader();
			pp.closeWindow('winDiv2');
		}
	
		
		</script>
</html>